package com.foruo.demo.spring;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestMe {

    public static void main(String[] args){
//        /** 原始用法 */
//        Tool tool = new Gun();
//        Person person = new Person(tool);
//        person.execute();

        /** 依赖注入 */
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("config.xml");
        Person personNew = (Person)classPathXmlApplicationContext.getBean("person");
        personNew.execute();
        classPathXmlApplicationContext.close();
    }
}
